package com.example.kotlinlearn.kotlinLearn

import java.io.*

fun main(){
    val play = play1()
    play.play()
    val file:File = File("C:\\Users\\kuangkuang\\Pictures\\a.lrc")
    println(file.length())
    val content = StringBuilder()
    val input = FileInputStream(file)
    val reader = BufferedReader(InputStreamReader(input))
    reader.use {
        reader.forEachLine {
            content.append(it)
        }
    }
    input.close()
    val arrayList = lrcUtils(content.toString())
    var i = 0
    while (i<arrayList.size-1){
        i++
        println(arrayList[i])
    }
}

fun lrcUtils(content:String):ArrayList<String>{
    val lrcList = ArrayList<String>()
    val sb = StringBuilder()
    for (i in content){
        if ('['==i){
            lrcList.add(sb.toString())
            sb.clear()
        }
        sb.append(i)
    }
    return lrcList
}


class play1:play{

    override fun play() {
        super.play()
        println("play1开始播放")
    }

    override fun pause() {
        println("play1暂停")
    }
}

class play2:play{
    override fun play() {
        println("play2开始播放")
    }

    override fun pause() {
        println("play2暂停")
    }
}

interface play{

    fun play(){
        println("播放")
    }

    fun pause()
}